﻿#region Using directives

using System;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;

using dmoz.Entities;
using dmoz.Data;

#endregion

namespace dmoz.Data.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="ImportProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract partial class ImportProviderBaseCore : EntityProviderBase<dmoz.Entities.Import, dmoz.Entities.ImportKey>
	{		
		#region Get from Many To Many Relationship Functions
		#endregion	
		
		#region Delete Methods

		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to delete.</param>
		/// <returns>Returns true if operation suceeded.</returns>
		public override bool Delete(TransactionManager transactionManager, dmoz.Entities.ImportKey key)
		{
			return Delete(transactionManager, key.IdRow);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="idRow">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public bool Delete(System.Int32 idRow)
		{
			return Delete(null, idRow);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="idRow">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public abstract bool Delete(TransactionManager transactionManager, System.Int32 idRow);		
		
		#endregion Delete Methods
		
		#region Get By Foreign Key Functions
		#endregion

		#region Get By Index Functions
		
		/// <summary>
		/// 	Gets a row from the DataSource based on its primary key.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to retrieve.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <returns>Returns an instance of the Entity class.</returns>
		public override dmoz.Entities.Import Get(TransactionManager transactionManager, dmoz.Entities.ImportKey key, int start, int pageLength)
		{
			return GetByIdRow(transactionManager, key.IdRow, start, pageLength);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key PK_Import index.
		/// </summary>
		/// <param name="idRow"></param>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.Import"/> class.</returns>
		public dmoz.Entities.Import GetByIdRow(System.Int32 idRow)
		{
			int count = -1;
			return GetByIdRow(null,idRow, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_Import index.
		/// </summary>
		/// <param name="idRow"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.Import"/> class.</returns>
		public dmoz.Entities.Import GetByIdRow(System.Int32 idRow, int start, int pageLength)
		{
			int count = -1;
			return GetByIdRow(null, idRow, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_Import index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="idRow"></param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.Import"/> class.</returns>
		public dmoz.Entities.Import GetByIdRow(TransactionManager transactionManager, System.Int32 idRow)
		{
			int count = -1;
			return GetByIdRow(transactionManager, idRow, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_Import index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="idRow"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.Import"/> class.</returns>
		public dmoz.Entities.Import GetByIdRow(TransactionManager transactionManager, System.Int32 idRow, int start, int pageLength)
		{
			int count = -1;
			return GetByIdRow(transactionManager, idRow, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_Import index.
		/// </summary>
		/// <param name="idRow"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.Import"/> class.</returns>
		public dmoz.Entities.Import GetByIdRow(System.Int32 idRow, int start, int pageLength, out int count)
		{
			return GetByIdRow(null, idRow, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_Import index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="idRow"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.Import"/> class.</returns>
		public abstract dmoz.Entities.Import GetByIdRow(TransactionManager transactionManager, System.Int32 idRow, int start, int pageLength, out int count);
						
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key IX_Import_Catid index.
		/// </summary>
		/// <param name="catid"></param>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.TList&lt;Import&gt;"/> class.</returns>
		public dmoz.Entities.TList<Import> GetByCatid(System.Int32 catid)
		{
			int count = -1;
			return GetByCatid(null,catid, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the IX_Import_Catid index.
		/// </summary>
		/// <param name="catid"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.TList&lt;Import&gt;"/> class.</returns>
		public dmoz.Entities.TList<Import> GetByCatid(System.Int32 catid, int start, int pageLength)
		{
			int count = -1;
			return GetByCatid(null, catid, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the IX_Import_Catid index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="catid"></param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.TList&lt;Import&gt;"/> class.</returns>
		public dmoz.Entities.TList<Import> GetByCatid(TransactionManager transactionManager, System.Int32 catid)
		{
			int count = -1;
			return GetByCatid(transactionManager, catid, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the IX_Import_Catid index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="catid"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.TList&lt;Import&gt;"/> class.</returns>
		public dmoz.Entities.TList<Import> GetByCatid(TransactionManager transactionManager, System.Int32 catid, int start, int pageLength)
		{
			int count = -1;
			return GetByCatid(transactionManager, catid, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the IX_Import_Catid index.
		/// </summary>
		/// <param name="catid"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.TList&lt;Import&gt;"/> class.</returns>
		public dmoz.Entities.TList<Import> GetByCatid(System.Int32 catid, int start, int pageLength, out int count)
		{
			return GetByCatid(null, catid, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the IX_Import_Catid index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="catid"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.TList&lt;Import&gt;"/> class.</returns>
		public abstract dmoz.Entities.TList<Import> GetByCatid(TransactionManager transactionManager, System.Int32 catid, int start, int pageLength, out int count);
						
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key IX_Import_Language index.
		/// </summary>
		/// <param name="language"></param>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.TList&lt;Import&gt;"/> class.</returns>
		public dmoz.Entities.TList<Import> GetByLanguage(System.String language)
		{
			int count = -1;
			return GetByLanguage(null,language, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the IX_Import_Language index.
		/// </summary>
		/// <param name="language"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.TList&lt;Import&gt;"/> class.</returns>
		public dmoz.Entities.TList<Import> GetByLanguage(System.String language, int start, int pageLength)
		{
			int count = -1;
			return GetByLanguage(null, language, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the IX_Import_Language index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="language"></param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.TList&lt;Import&gt;"/> class.</returns>
		public dmoz.Entities.TList<Import> GetByLanguage(TransactionManager transactionManager, System.String language)
		{
			int count = -1;
			return GetByLanguage(transactionManager, language, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the IX_Import_Language index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="language"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.TList&lt;Import&gt;"/> class.</returns>
		public dmoz.Entities.TList<Import> GetByLanguage(TransactionManager transactionManager, System.String language, int start, int pageLength)
		{
			int count = -1;
			return GetByLanguage(transactionManager, language, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the IX_Import_Language index.
		/// </summary>
		/// <param name="language"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.TList&lt;Import&gt;"/> class.</returns>
		public dmoz.Entities.TList<Import> GetByLanguage(System.String language, int start, int pageLength, out int count)
		{
			return GetByLanguage(null, language, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the IX_Import_Language index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="language"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.TList&lt;Import&gt;"/> class.</returns>
		public abstract dmoz.Entities.TList<Import> GetByLanguage(TransactionManager transactionManager, System.String language, int start, int pageLength, out int count);
						
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key IX_Import_Resource index.
		/// </summary>
		/// <param name="resourcetype"></param>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.TList&lt;Import&gt;"/> class.</returns>
		public dmoz.Entities.TList<Import> GetByResourcetype(System.Int32? resourcetype)
		{
			int count = -1;
			return GetByResourcetype(null,resourcetype, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the IX_Import_Resource index.
		/// </summary>
		/// <param name="resourcetype"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.TList&lt;Import&gt;"/> class.</returns>
		public dmoz.Entities.TList<Import> GetByResourcetype(System.Int32? resourcetype, int start, int pageLength)
		{
			int count = -1;
			return GetByResourcetype(null, resourcetype, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the IX_Import_Resource index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="resourcetype"></param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.TList&lt;Import&gt;"/> class.</returns>
		public dmoz.Entities.TList<Import> GetByResourcetype(TransactionManager transactionManager, System.Int32? resourcetype)
		{
			int count = -1;
			return GetByResourcetype(transactionManager, resourcetype, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the IX_Import_Resource index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="resourcetype"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.TList&lt;Import&gt;"/> class.</returns>
		public dmoz.Entities.TList<Import> GetByResourcetype(TransactionManager transactionManager, System.Int32? resourcetype, int start, int pageLength)
		{
			int count = -1;
			return GetByResourcetype(transactionManager, resourcetype, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the IX_Import_Resource index.
		/// </summary>
		/// <param name="resourcetype"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.TList&lt;Import&gt;"/> class.</returns>
		public dmoz.Entities.TList<Import> GetByResourcetype(System.Int32? resourcetype, int start, int pageLength, out int count)
		{
			return GetByResourcetype(null, resourcetype, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the IX_Import_Resource index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="resourcetype"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="dmoz.Entities.TList&lt;Import&gt;"/> class.</returns>
		public abstract dmoz.Entities.TList<Import> GetByResourcetype(TransactionManager transactionManager, System.Int32? resourcetype, int start, int pageLength, out int count);
						
		#endregion "Get By Index Functions"
	
		#region Custom Methods
		
		
		#region _Import_TruncateMainTables 
		
		/// <summary>
		///	This method wrap the '_Import_TruncateMainTables' stored procedure. 
		/// </summary>
		/// <remark>This method is generate from a stored procedure.</remark>
		public void TruncateMainTables()
		{
			 TruncateMainTables(null, 0, int.MaxValue );
		}
		
		/// <summary>
		///	This method wrap the '_Import_TruncateMainTables' stored procedure. 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public void TruncateMainTables(int start, int pageLength)
		{
			 TruncateMainTables(null, start, pageLength );
		}
				
		/// <summary>
		///	This method wrap the '_Import_TruncateMainTables' stored procedure. 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public void TruncateMainTables(TransactionManager transactionManager)
		{
			 TruncateMainTables(transactionManager, 0, int.MaxValue );
		}
		
		/// <summary>
		///	This method wrap the '_Import_TruncateMainTables' stored procedure. 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public abstract void TruncateMainTables(TransactionManager transactionManager, int start, int pageLength );
		
		#endregion
		
		#region _Import_PostProcess 
		
		/// <summary>
		///	This method wrap the '_Import_PostProcess' stored procedure. 
		/// </summary>
		/// <remark>This method is generate from a stored procedure.</remark>
		public void PostProcess()
		{
			 PostProcess(null, 0, int.MaxValue );
		}
		
		/// <summary>
		///	This method wrap the '_Import_PostProcess' stored procedure. 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public void PostProcess(int start, int pageLength)
		{
			 PostProcess(null, start, pageLength );
		}
				
		/// <summary>
		///	This method wrap the '_Import_PostProcess' stored procedure. 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public void PostProcess(TransactionManager transactionManager)
		{
			 PostProcess(transactionManager, 0, int.MaxValue );
		}
		
		/// <summary>
		///	This method wrap the '_Import_PostProcess' stored procedure. 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public abstract void PostProcess(TransactionManager transactionManager, int start, int pageLength );
		
		#endregion
		
		#endregion

		#region Helper Functions	
		
		/// <summary>
		/// Fill a dmoz.Entities.TList&lt;Import&gt; From a DataReader.
		/// </summary>
		/// <param name="reader">Datareader</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">number of rows.</param>
		/// <returns>a <see cref="dmoz.Entities.TList&lt;Import&gt;"/></returns>
		public static dmoz.Entities.TList<Import> Fill(IDataReader reader, dmoz.Entities.TList<Import> rows, int start, int pageLength)
		{
		// advance to the starting row
		for (int i = 0; i < start; i++)
		{
			if (!reader.Read())
			return rows; // not enough rows, just return
		}
		for (int i = 0; i < pageLength; i++)
		{
			if (!reader.Read())
			break; // we are done
			string key = null;
			
			dmoz.Entities.Import c = null;
			if (DataRepository.Provider.UseEntityFactory)
			{
			key = new System.Text.StringBuilder("Import")
			.Append("|").Append((reader.IsDBNull(((int)dmoz.Entities.ImportColumn.IdRow - 1))?(int)0:(System.Int32)reader[((int)dmoz.Entities.ImportColumn.IdRow - 1)]).ToString()).ToString();
			c = EntityManager.LocateOrCreate<Import>(
			key.ToString(), // EntityTrackingKey
			"Import",  //Creational Type
			DataRepository.Provider.EntityCreationalFactoryType,  //Factory used to create entity
			DataRepository.Provider.EnableEntityTracking); // Track this entity?
			}
			else
			{
			c = new dmoz.Entities.Import();
			}
			
			if (!DataRepository.Provider.EnableEntityTracking ||
			c.EntityState == EntityState.Added ||
			(DataRepository.Provider.EnableEntityTracking &&
			((DataRepository.Provider.CurrentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
			(DataRepository.Provider.CurrentLoadPolicy == LoadPolicy.DiscardChanges && (c.EntityState == EntityState.Unchanged ||
								c.EntityState == EntityState.Changed)))))
						{
			c.SuppressEntityEvents = true;
			c.IdRow = (System.Int32)reader["idRow"];
			c.Catid = (System.Int32)reader["catid"];
			c.Resourcetype = reader.IsDBNull(reader.GetOrdinal("resourcetype")) ? null : (System.Int32?)reader["resourcetype"];
			c.Value = reader.IsDBNull(reader.GetOrdinal("value")) ? null : (System.String)reader["value"];
			c.Title = reader.IsDBNull(reader.GetOrdinal("title")) ? null : (System.String)reader["title"];
			c.Language = reader.IsDBNull(reader.GetOrdinal("language")) ? null : (System.String)reader["language"];
			c.IdLabel = reader.IsDBNull(reader.GetOrdinal("idLabel")) ? null : (System.Int32?)reader["idLabel"];
			c.EntityTrackingKey = key;
			c.AcceptChanges();
			c.SuppressEntityEvents = false;
			}
			rows.Add(c);
		}
		return rows;
		}		
		/// <summary>
		/// Refreshes the <see cref="dmoz.Entities.Import"/> object from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to read from.</param>
		/// <param name="entity">The <see cref="dmoz.Entities.Import"/> object to refresh.</param>
		public static void RefreshEntity(IDataReader reader, dmoz.Entities.Import entity)
		{
			if (!reader.Read()) return;
			
			entity.IdRow = (System.Int32)reader["idRow"];
			entity.Catid = (System.Int32)reader["catid"];
			entity.Resourcetype = reader.IsDBNull(reader.GetOrdinal("resourcetype")) ? null : (System.Int32?)reader["resourcetype"];
			entity.Value = reader.IsDBNull(reader.GetOrdinal("value")) ? null : (System.String)reader["value"];
			entity.Title = reader.IsDBNull(reader.GetOrdinal("title")) ? null : (System.String)reader["title"];
			entity.Language = reader.IsDBNull(reader.GetOrdinal("language")) ? null : (System.String)reader["language"];
			entity.IdLabel = reader.IsDBNull(reader.GetOrdinal("idLabel")) ? null : (System.Int32?)reader["idLabel"];
			entity.AcceptChanges();
		}
		
		/// <summary>
		/// Refreshes the <see cref="dmoz.Entities.Import"/> object from the <see cref="DataSet"/>.
		/// </summary>
		/// <param name="dataSet">The <see cref="DataSet"/> to read from.</param>
		/// <param name="entity">The <see cref="dmoz.Entities.Import"/> object.</param>
		public static void RefreshEntity(DataSet dataSet, dmoz.Entities.Import entity)
		{
			DataRow dataRow = dataSet.Tables[0].Rows[0];
			
			entity.IdRow = (System.Int32)dataRow["idRow"];
			entity.Catid = (System.Int32)dataRow["catid"];
			entity.Resourcetype = Convert.IsDBNull(dataRow["resourcetype"]) ? null : (System.Int32?)dataRow["resourcetype"];
			entity.Value = Convert.IsDBNull(dataRow["value"]) ? null : (System.String)dataRow["value"];
			entity.Title = Convert.IsDBNull(dataRow["title"]) ? null : (System.String)dataRow["title"];
			entity.Language = Convert.IsDBNull(dataRow["language"]) ? null : (System.String)dataRow["language"];
			entity.IdLabel = Convert.IsDBNull(dataRow["idLabel"]) ? null : (System.Int32?)dataRow["idLabel"];
			entity.AcceptChanges();
		}
		#endregion 
		
		#region DeepLoad Methods
		/// <summary>
		/// Deep Loads the <see cref="IEntity"/> object with criteria based of the child 
		/// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
		/// </summary>
		/// <remarks>
		/// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
		/// </remarks>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">The <see cref="dmoz.Entities.Import"/> object to load.</param>
		/// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
		/// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
		/// <param name="childTypes">dmoz.Entities.Import Property Collection Type Array To Include or Exclude from Load</param>
		/// <param name="innerList">A collection of child types for easy access.</param>
	    /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
	    /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
		internal override void DeepLoad(TransactionManager transactionManager, dmoz.Entities.Import entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
		{
			if(entity == null)
				return;
			
			//used to hold DeepLoad method delegates and fire after all the local children have been loaded.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			
			//Fire all DeepLoad Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			deepHandles = null;
		}
		
		#endregion 
		
		#region DeepSave Methods

		/// <summary>
		/// Deep Save the entire object graph of the dmoz.Entities.Import object with criteria based of the child 
		/// Type property array and DeepSaveType.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entity">dmoz.Entities.Import instance</param>
		/// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param>
		/// <param name="childTypes">dmoz.Entities.Import Property Collection Type Array To Include or Exclude from Save</param>
		/// <param name="innerList">A Hashtable of child types for easy access.</param>
		internal override bool DeepSave(TransactionManager transactionManager, dmoz.Entities.Import entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList)
		{	
			if (entity == null)
				return false;
							
			#region Composite Parent Properties
			//Save Source Composite Properties, however, don't call deep save on them.  
			//So they only get saved a single level deep.
			#endregion Composite Parent Properties

			// Save Root Entity through Provider
			if (!entity.IsDeleted)
				this.Save(transactionManager, entity);
			
			//used to hold DeepSave method delegates and fire after all the local children have been saved.
			Dictionary<Delegate, object> deepHandles = new Dictionary<Delegate, object>();
			//Fire all DeepSave Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			
			// Save Root Entity through Provider, if not already saved in delete mode
			if (entity.IsDeleted)
				this.Save(transactionManager, entity);
				

			deepHandles = null;
						
			return true;
		}
		#endregion
	} // end class
	
	#region ImportChildEntityTypes
	
	///<summary>
	/// Enumeration used to expose the different child entity types 
	/// for child properties in <c>dmoz.Entities.Import</c>
	///</summary>
	public enum ImportChildEntityTypes
	{
	}
	
	#endregion ImportChildEntityTypes
	
	#region ImportFilterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilterBuilder&lt;ImportColumn&gt;"/> class
	/// that is used exclusively with a <see cref="Import"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class ImportFilterBuilder : SqlFilterBuilder<ImportColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the ImportFilterBuilder class.
		/// </summary>
		public ImportFilterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the ImportFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public ImportFilterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the ImportFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public ImportFilterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion ImportFilterBuilder
	
	#region ImportParameterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ParameterizedSqlFilterBuilder&lt;ImportColumn&gt;"/> class
	/// that is used exclusively with a <see cref="Import"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class ImportParameterBuilder : ParameterizedSqlFilterBuilder<ImportColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the ImportParameterBuilder class.
		/// </summary>
		public ImportParameterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the ImportParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public ImportParameterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the ImportParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public ImportParameterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion ImportParameterBuilder
} // end namespace
